﻿namespace HHFileViewServer
{
    /// <summary>
    /// 文件基础信息
    /// </summary>
    public class BaseFileInfo
    {
        /// <summary>
        /// 文件名（不包含扩展名）
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 相对路径
        /// </summary>
        public string Path { get; set; }
        /// <summary>
        /// 绝对路径
        /// </summary>
        public string AbsolutePath { get; set; }
        /// <summary>
        /// 文件类型
        /// </summary>
        public FILETYPE FileType { get; set; }
        /// <summary>
        /// 扩展名
        /// </summary>
        public string Extension { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string Icon { get; set; }
        /// <summary>
        /// 文件集
        /// </summary>
        public List<BaseFileInfo> Files { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    public class ResponseDto
    {
        /// <summary>
        /// 是否预览成功
        /// </summary>
        public bool IsSuccess { get; set; } = true;
        /// <summary>
        /// 异常信息
        /// </summary>
        public string ErrMsg { get; set; }
        /// <summary>
        /// 文件信息
        /// </summary>
        public BaseFileInfo FileInfo { get; set; }
    }

    /// <summary>
    /// 响应
    /// </summary>
    public class Result
    {
        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static ResponseDto Fail(string errMsg)
        {
            return new ResponseDto()
            {
                IsSuccess = false,
                ErrMsg = errMsg
            };
        }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="baseFileInfo"></param>
        /// <returns></returns>
        public static ResponseDto Success(BaseFileInfo baseFileInfo)
        {
            return new ResponseDto()
            {
                IsSuccess = true,
                FileInfo = baseFileInfo
            };
        }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="baseFileInfo"></param>
        /// <returns></returns>
        public static ResponseDto Success(string msg, BaseFileInfo baseFileInfo)
        {
            return new ResponseDto()
            {
                IsSuccess = true,
                ErrMsg = msg,
                FileInfo = baseFileInfo
            };
        }
    }
}
